From 9a25a585e5ab747237ff12fb312f615e8ddaabbd Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 11 Apr 2005 21:07:16 +0000 Subject: [PATCH] Move icon_descr_is_dynamic and shortname_is_synthetic into a bitfield. --- gpsbabel/csv_util.c | 2 +- gpsbabel/defs.h | 13 ++++- gpsbabel/geo.c | 2 +- gpsbabel/geoniche.c | 2 +- gpsbabel/gpilots.c | 2 +- gpsbabel/gpx.c | 4 +- gpsbabel/hiketech.c | 2 +- gpsbabel/jeeps/gpsport.h | 2 +- gpsbabel/mingw/wintesto.cmd | 109 +++++++++++++++++++++++++++++++++++- gpsbabel/route.c | 2 +- gpsbabel/waypt.c | 4 +- 11 files changed, 130 insertions(+), 14 deletions(-) diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 26625e4fa..42d67b985 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -639,7 +639,7 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) } else if (strcmp(fmp->key, "ICON_DESCR") == 0) { wpt->icon_descr = csv_stringtrim(s, "", 0); - wpt->icon_descr_is_dynamic = 1; + wpt->wpt_flags.icon_descr_is_dynamic = 1; } else /* LATITUDE CONVERSIONS**************************************************/ diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index ae933b01f..e979c6d86 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -158,12 +158,21 @@ typedef struct { an1_copy copy; } an1_base; +/* + * Misc bitfields inside struct waypoint; + */ +typedef struct { + unsigned int icon_descr_is_dynamic:1; + unsigned int shortname_is_synthetic:1; +} wp_flags; + /* * This is a waypoint, as stored in the GPSR. It tries to not * cater to any specific model or protocol. Anything that needs to * be truncated, edited, or otherwise trimmed should be done on the * way to the target. */ + typedef struct { queue Q; /* Master waypoint q. Not for use by modules. */ @@ -208,8 +217,8 @@ typedef struct { char *notes; char *url; char *url_link_text; - int icon_descr_is_dynamic; - int shortname_is_synthetic; + + wp_flags wpt_flags; const char *icon_descr; time_t creation_time; /* standardized in UTC/GMT */ int centiseconds; /* Optional hundredths of a second. */ diff --git a/gpsbabel/geo.c b/gpsbabel/geo.c index c93cdc559..c8ace7244 100644 --- a/gpsbabel/geo.c +++ b/gpsbabel/geo.c @@ -109,7 +109,7 @@ void wpt_link(const char *args, const char **attrv) void wpt_type(const char *args, const char **unused) { - wpt_tmp->icon_descr_is_dynamic = 1; + wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; wpt_tmp->icon_descr = xstrdup(args); } diff --git a/gpsbabel/geoniche.c b/gpsbabel/geoniche.c index ff4a5a5d5..7fb0d4a7d 100644 --- a/gpsbabel/geoniche.c +++ b/gpsbabel/geoniche.c @@ -335,7 +335,7 @@ data_read(void) wpt->longitude = lon; wpt->altitude = alt; wpt->icon_descr = category; - wpt->icon_descr_is_dynamic = 1; + wpt->wpt_flags.icon_descr_is_dynamic = 1; if (gid[0]) { diff --git a/gpsbabel/gpilots.c b/gpsbabel/gpilots.c index 24cd5e606..6af407510 100644 --- a/gpsbabel/gpilots.c +++ b/gpsbabel/gpilots.c @@ -277,7 +277,7 @@ data_read(void) wpt_tmp->depth = fi.f; fi.i = le_read32(&rec->wpt.d108.dist); wpt_tmp->proximity = fi.f; - wpt_tmp->icon_descr_is_dynamic = 0; + wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0; wpt_tmp->icon_descr = mps_find_desc_from_icon_number((rec->wpt.d108.smbl[1] << 8) + rec->wpt.d108.smbl[0], PCX); waypt_add(wpt_tmp); break; diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index 78f6590d7..1eb5d7021 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -750,7 +750,7 @@ gpx_end(void *data, const char *el) case tt_rte_rtept_sym: case tt_trk_trkseg_trkpt_sym: wpt_tmp->icon_descr = xstrdup(cdatastrp); - wpt_tmp->icon_descr_is_dynamic = 1; + wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; break; case tt_wpt_time: case tt_trk_trkseg_trkpt_time: @@ -1188,7 +1188,7 @@ gpx_track_disp(const waypoint *waypointp) /* GPX doesn't require a name on output, so if we made one up * on input, we might as well say nothing. */ - if (!waypointp->shortname_is_synthetic) { + if (!waypointp->wpt_flags.shortname_is_synthetic) { write_optional_xml_entity(ofd, " ", "name", waypointp->shortname); } diff --git a/gpsbabel/hiketech.c b/gpsbabel/hiketech.c index bf09e4c09..a1d026485 100644 --- a/gpsbabel/hiketech.c +++ b/gpsbabel/hiketech.c @@ -181,7 +181,7 @@ void ht_ident(const char *args, const char **unused) void ht_sym(const char *args, const char **unused) { wpt_tmp->icon_descr = xstrdup(args); - wpt_tmp->icon_descr_is_dynamic = 1; + wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1; } void ht_lat(const char *args, const char **unused) diff --git a/gpsbabel/jeeps/gpsport.h b/gpsbabel/jeeps/gpsport.h index c640c42a7..dd23cc401 100644 --- a/gpsbabel/jeeps/gpsport.h +++ b/gpsbabel/jeeps/gpsport.h @@ -8,7 +8,7 @@ */ typedef unsigned char UC; -typedef uint16 US; +typedef gbuint16 US; typedef gbuint16 uint16; typedef gbint16 int16; typedef gbuint32 uint32; diff --git a/gpsbabel/mingw/wintesto.cmd b/gpsbabel/mingw/wintesto.cmd index 174479214..86c14de10 100644 --- a/gpsbabel/mingw/wintesto.cmd +++ b/gpsbabel/mingw/wintesto.cmd @@ -126,6 +126,27 @@ DEL %TMPDIR%\tiger @echo. CALL :COMPARE %TMPDIR%\tiger %TMPDIR%\tiger2 +REM +REM Lowrance USR. Binary, and also slightly lossy because of the math to +REM convert lat/long. It also doesn't support description, which makes it +REM awkward to test. +REM +DEL %TMPDIR%\lowrance1.usr +@echo on +@echo Testing... +%PNAME% -i geo -f geocaching.loc -o lowranceusr -F %TMPDIR%\lowrance1.usr +@echo off +@echo. +CALL :BINCOMPARE %TMPDIR%\lowrance1.usr reference\lowrance.usr +@echo on +@echo Testing... +%PNAME% -i lowranceusr -f %TMPDIR%\lowrance1.usr -o lowranceusr -F %TMPDIR%\lowrance1.usr +@echo off +@echo. +REM And because of the FP rounding, we can't even read our file, write it back +REM and get the same data. Sigh. +REM bincompare reference/lowrance.usr ${TMPDIR}/lowrance1.usr + REM CSV (Comma separated value) data. @echo on @@ -250,7 +271,7 @@ REM identical reference. %PNAME% -i holux -f reference\paris.wpo -o holux -F %TMPDIR%\paris.wpo @echo off @echo. -CALL :COMPARE reference\paris.wpo %TMPDIR%\paris.wpo +REM compare reference/paris.wpo ${TMPDIR}/paris.wpo REM Magellan NAV Companion for PalmOS REM This format is hard to test, because each record and the database itself @@ -837,6 +858,59 @@ CALL :COMPARE %TMPDIR%\igc_sed.out reference\igc2_igc.out @echo. CALL :COMPARE %TMPDIR%\igc.gpx reference\igc2_gpx.out +REM +REM Google Maps XML test +REM +DEL %TMPDIR%\google.out +@echo on +@echo Testing... +%PNAME% -i google -f reference\google.xml -o arc -F %TMPDIR%\google.out +@echo off +@echo. +CALL :COMPARE %TMPDIR%\google.out reference\google.arc + +DEL %TMPDIR%\google.out +@echo on +@echo Testing... +%PNAME% -i google -f reference\google.js -o arc -F %TMPDIR%\google.out +@echo off +@echo. +CALL :COMPARE %TMPDIR%\google.out reference\google.arc + +REM +REM DeLorme .an1 tests +REM +DEL %TMPDIR%\an1.out +@echo on +@echo Testing... +%PNAME% -i an1 -f reference\foo.an1 -o csv -F %TMPDIR%\an1.out +@echo off +@echo. +CALL :COMPARE %TMPDIR%\an1.out reference\an1-in.ref + +DEL %TMPDIR%\an1.out +@echo on +@echo Testing... +%PNAME% -i an1 -f reference\foo.an1 -o an1 -F %TMPDIR%\an1.out +@echo off +@echo. +CALL :COMPARE %TMPDIR%\an1.out reference\an1-an1.ref + +DEL %TMPDIR%\an1.out +@echo on +@echo Testing... +%PNAME% -i xmap -f reference\xmap -o an1 -F %TMPDIR%\an1.out +@echo off +@echo. +CALL :COMPARE %TMPDIR%\an1.out reference\an1-out.ref + +DEL %TMPDIR%\an1.out +@echo on +@echo Testing... +%PNAME% -i google -f reference\google.js -o an1 -F %TMPDIR%\an1.out +@echo off +@echo. +CALL :COMPARE %TMPDIR%\an1.out reference\an1-line-out.ref REM REM XCSV "human readable" tests @@ -901,3 +975,36 @@ REM @echo off @echo. +REM +REM 'tabsep' isn't really tested in any non-trivial way, but we do exercise +REM it. +REM + +@echo on +@echo Testing... +%PNAME% -i geo -f geocaching.loc -o tabsep -F - | ${PNAME} -i tabsep -f - -o geo -F %TMPDIR%\tabsep.out +%PNAME% -i geo -f geocaching.loc -o geo -F %TMPDIR%\geotabsep.out +@echo off +@echo. + +REM +REM Now do the same for custom - it has the same issues. +REM + +CALL :COMPARE %TMPDIR%\tabsep.out %TMPDIR%\geotabsep.out +@echo on +@echo Testing... +%PNAME% -i geo -f geocaching.loc -o custom -F - | ${PNAME} -i custom -f - -o geo -F %TMPDIR%\custom.out +%PNAME% -i geo -f geocaching.loc -o geo -F %TMPDIR%\geocustom.out +@echo off +@echo. + +REM +REM Write something to the various output-only formats +REM +@echo on +@echo Testing... +%PNAME% -i geo -f geocaching.loc -o text -F %TMPDIR%\text.out -o html -F %TMPDIR%\html.out -o vcard -F %TMPDIR%\vcard.out #-o palmdoc -F %TMPDIR%\pd.out +@echo off +@echo. + diff --git a/gpsbabel/route.c b/gpsbabel/route.c index 545da8210..750d13988 100644 --- a/gpsbabel/route.c +++ b/gpsbabel/route.c @@ -104,7 +104,7 @@ route_add_wpt(route_head *rte, waypoint *wpt) char tmpnam[10]; snprintf(tmpnam, sizeof(tmpnam), "RPT%03d",rte_waypts); wpt->shortname = xstrdup(tmpnam); - wpt->shortname_is_synthetic = 1; + wpt->wpt_flags.shortname_is_synthetic = 1; } } diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index 14305d98c..f45633a65 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -50,7 +50,7 @@ waypt_dupe(const waypoint *wpt) tmp->url = xstrdup(wpt->url); if (wpt->url_link_text) tmp->url_link_text = xstrdup(wpt->url_link_text); - if (wpt->icon_descr && wpt->icon_descr_is_dynamic) + if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) tmp->icon_descr = xstrdup(wpt->icon_descr); if (wpt->gc_data.desc_short.utfstring) { tmp->gc_data.desc_short.utfstring = @@ -262,7 +262,7 @@ waypt_free( waypoint *wpt ) if (wpt->url_link_text) { xfree(wpt->url_link_text); } - if (wpt->icon_descr && wpt->icon_descr_is_dynamic) { + if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) { xfree((char *)(void *)wpt->icon_descr); } if (wpt->gpx_extras) { -- 2.30.2